package com.pfmcsg;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.pfm.animaciones.Main;
import com.pfm.cuento.R;
import com.pfm.fisicas.Physics;
import com.pfm.fisicas.PhysicsExample;
import com.pfm.graficos.LoadGriferia;
import com.pfm.graficos.LoadLibro;
import com.pfm.graficos.LoadMultiMD2;
import com.pfm.graficos.LoadObjFile;
import com.pfm.graficos.RotatingPlanets;
import com.pfm.libro.pagina1;
import com.pfm.menu.Indice;

public class pfmcsg extends ListActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      String[] ejemplos = getResources().getStringArray(R.array.ejemplos_array);
      setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, ejemplos));
      
//      setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, COUNTRIES));

      ListView lv = getListView();
      lv.setTextFilterEnabled(true);
 
//        	Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
//              Toast.LENGTH_SHORT).show();
        	
//        	Context context = getApplicationContext();
//        	CharSequence text = ((TextView) view).getText();
//        	int duration = Toast.LENGTH_SHORT;
//        	
//        	Toast.makeText(context, text, duration).show();
        	
//        	Toast.makeText(PfmCsg.this, "" + position, Toast.LENGTH_SHORT).show();
        	
        	
    }
    
	 protected void onListItemClick(ListView l, android.view.View v, int position, long id) {
	      super.onListItemClick(l, v, position, id);
	      //String nombre = l.getAdapter().getItem( position ).toString();
	      
	      //Muestra un mensaje en pantalla, en este caso el texto del elemento del menu
	      Toast.makeText(getApplicationContext(), ((TextView) v).getText(),
	              Toast.LENGTH_SHORT).show();
	      
	      Intent i;
	      
		    //Iniciamos una nueva actividad dependiendo de la posición en el menu que este
	      switch(position)
	      {
	      		case 0: //M2D//        	Toast.makeText(PfmCsg.this, "" + position, Toast.LENGTH_SHORT).show();
	              	Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	              	i = new Intent(v.getContext(), LoadMultiMD2.class);
		  		      i.putExtra("position", position);
		  		      startActivity(i);
	      			break;
	      		case 1:	 //Obj
	              	Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	              	i = new Intent(v.getContext(), LoadObjFile.class);
		  		      i.putExtra("position", position);
		  		      startActivity(i);
	      			break;
	      		case 2:	 //Planetas
	    		      i = new Intent(v.getContext(), RotatingPlanets.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	      			
	      			break;
	      		case 3:	 //Lata
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), LoadLibro.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	      			break;
	      		case 4:	 //Griferia
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), LoadGriferia.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	      			break;
	      		case 5:	 //Fisicas JBOX2D
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), Physics.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	      			break;
	      		case 6:	 //Fisicas AndEngine
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), PhysicsExample.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	      			break;
	      		case 7:	 //Libro
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), pagina1.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	      			break;
	      		case 8:	 //Page curl effect
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), Main.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	
//	      			v.startAnimation(AnimationUtils.loadAnimation(HomeScreen.this, R.anim.slideleft));
	      			
//	      			setContentView(R.layout.sign_in);
//	      		    ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper);
//
//	      		HomeScreen s = new HomeScreen(getApplicationContext(), getCurrentFocus(), viewFlipper);
	      			break;	
	      		case 9:	 //Page curl effect
	      			  Toast.makeText(pfmcsg.this, "" + position, Toast.LENGTH_SHORT).show();
	    		      i = new Intent(v.getContext(), Indice.class);
	    		      i.putExtra("position", position);
	    		      startActivity(i);
	    		      break;
	      		default:
	      			break;
	      	
	      }
	      
	 }
    
//    static final String[] COUNTRIES = new String[] {
//        "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
//        "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
//      };
}